package com.wenqiner.requesttool.util;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.wenqiner.requesttool.core.tool.StoreMapJsonSerializer;
import com.wenqiner.requesttool.core.tool.StringUnicodeSerializer;

import java.util.LinkedHashMap;

/**
 * @author rhf
 * @date 2023-03-29
 **/
public class ObjectMapperUtil {
    public static ObjectMapper objectMapper;

    static {
        objectMapper = new ObjectMapper();
        SimpleModule simpleModule = new SimpleModule();
        simpleModule.addSerializer(LinkedHashMap.class, new StoreMapJsonSerializer());
        simpleModule.addSerializer(String.class, new StringUnicodeSerializer());
        objectMapper.registerModule(simpleModule);
        objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
        objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
    }

    public static ObjectMapper getMapper(){
        return objectMapper;
    }

    public static void main(String[] args) {

    }
}
